﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo02
{
    class Class1
    {
        private int h;
        private int d;
        private double r;


        public int H
        {
            get { return this.h; }
          set {
                if (h<0)
                {
                    Console.WriteLine("输入有误");
                }
                else
                {
                    this.h = value;
                }
            }
        }
        public int D
        {
            get { return this.d; }
            set
            {
                if (d < 0)
                {
                    Console.WriteLine("输入有误");
                }
                else
                {
                    this.d = value;
                }
            }
        }
        public double R
        {
            get { return this.r; }
            set
            {
                if (r< 0)
                {
                    Console.WriteLine("输入有误");
                }
                else
                {
                    this.r = value;
                }
            }
        }

        public void Y()
        {
            Console.WriteLine("面积是"+(this.r+(this.h*this.d))); 
        }

        //圆形
        public Class1(double r)
        {

            this.r = r * r * 3.14;
                }
        //长方形
        public Class1(int h, int d)
        {
            this.h = h;
            this.d = d;
        }
    }
}
